﻿#ifndef HDCDOMEVIDEOGROUP_H
#define HDCDOMEVIDEOGROUP_H
#include <QtWidgets>
#include "math.h"
class HDCDomeVideoPanel;
class HPictureViewPanel;
class HDCDomeVideoGroup : public QWidget
{
    Q_OBJECT
public:
    HDCDomeVideoGroup(QWidget *parent = 0);
    ~HDCDomeVideoGroup();

    void                      setSpacing(int nSpacing);
    void                      setMargins(int nLeft,int nTop,int nRight,int nBottom);
    void                      setVideoCount(int nCount);
	int                       getCurrentVideoCount();
	void                      setCurrentVideoCount(int nCount);
    void                      setPanelChecked(int nIndex, bool bChecked);
	void                      setVideoSelectEnable(bool bEnable);
	void                      setPanelResolution(int nVideoID,QString strResolution);
	HDCDomeVideoPanel         *currentVideoPanel();
    QList<HDCDomeVideoPanel*> getAllVideoPanels();
	void                      topVideoPanel(HDCDomeVideoPanel *videoPanel);
	void                      setCurrentVideoPanel(int nIndex);//设置当前视频显示区域
	bool                      isVideoPlaying();//判断绘制区域是否被选中，用来判断是否新增加一页
    bool                      isVideoPanelChecked();//判断是否选中窗口为焦点窗口
	void                      closeOpenedVideo(HDCDomeVideoPanel *wndVideoPanel);
	HDCDomeVideoPanel*        getVideoPanel(QString strVideoID); //根据打开设备id获取对应的绘制窗口
    bool                      isHasOpenVideo();//判断m_pwndVideoGroup窗口是否有打开的设备
    void                      initGridInfo(int nVideoCount);
	QString                   getDeviceIDFromVideoPanel(HDCDomeVideoPanel *wndVideoPanel);
	void                      getAllDeviceIDs(QList<QString> &lstIds);
    int                       getCurrentPanelFocusIndex();//获得当前焦点窗口的索引
    void                      setVideoPanel(HDCDomeVideoPanel *pwndVideoPanel);
    void                      clearListVidePanels();
protected:
    void                      mousePressEvent(QMouseEvent *event);

private:
    void                      initUI();
//    void                      initGridInfo(int nVideoCount);
    void                      viewPictures(QString strPicPath);

private slots:
    void                      sltSetCurrentVideoPanel();
	void                      sltPanelDoubleClicked();
    void                      sltViewWarningInfo();
    void                      sltPictureViewPanelClosed();
    void                      sltBitStreamChanged(int nBitStream);
private:
    int                       m_nSpacing;
    int                       m_nMarginLeft;
    int                       m_nMarginTop;
    int                       m_nMarginRight;
    int                       m_nMarginBottom;

    QList<HDCDomeVideoPanel*> m_lstVideos;
	HDCDomeVideoPanel         *m_pwndCurrentVideoPanel;
    HDCDomeVideoPanel         *m_pwndViewWarningVideoPanel;

    QGridLayout               *m_pglMain;
	//QStackedLayout            *m_pslVideoPanel;

	int                       m_nCurrentVideoCount;

    HPictureViewPanel         *m_pPictureViewPanel;

	bool                      m_bEnlargeOneVideo;
	bool                      m_bVideoSelectable;

    bool                      m_bVideoPanelChecked;

signals:
    //void                      sigCloseCurrentVideo();
	void                      sigCloseVideo(HDCDomeVideoPanel*);
    void                      sigCloseCurrentBroadCast();
    void                      sigOpenCurrentVideoBroadCast();
	void                      sigVideoLayoutChanged();
    void                      sigBitStreamChanged(int nstreamType,HDCDomeVideoPanel *videoPanel);
	void                      sigVideoWarningStateChanged(QHash<QString,QVariant> hashData,bool bWarning);
//	void                      sigVideoPanelChanged(HDCDomeVideoPanel*);
	void                      sigsetVideoCount(int nCount);
};

#endif
